package Cau9;

import java.awt.Graphics;
import java.io.Serializable;


public class Triangle implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int[] xPoint;
	private int[] yPoint;
	
	public Triangle(){
		setTriangle(0,0,0,0);
	}
	public void setTriangle(int x,int y,int w,int h){
		xPoint = new int[4];
		yPoint = new int[4];
		xPoint[0] = x + w/2;
		xPoint[1] = x + w;
		xPoint[2] = x;
		xPoint[3] = xPoint[0];
		yPoint[0] = y;
		yPoint[1] = y + h;
		yPoint[2] = y + h;
		yPoint[3] = yPoint[0];
		
	}
	public void drawTriangle(Graphics g){		
		g.drawPolygon(xPoint, yPoint, 4);
	}
	public void fillTriangle(Graphics g){				
		g.fillPolygon(xPoint, yPoint, 3);
	}
}
